const User = {
    state: {
        name: "",
        photo:"",
        isLogin: false,
        token: "",
        id:"",
    },
    getters: {

    },
    mutations: {
        denglu(state, data) {
            state.name = data.name;
            state.token = data.token;
            state.isLogin = true;
            state.photo = data.photo;
            state.id = data.id;

            localStorage.setItem("id",data.id);
            localStorage.setItem("isLogin", true);
            localStorage.setItem("token", data.token);
            localStorage.setItem("name", data.name);
            localStorage.setItem("photo", data.photo);
        },
        logout(state) {
            localStorage.clear();
            state.name = "";
            state.token = "";
            state.isLogin = false;
            state.photo = "";
        },
        update(state, data) {
            localStorage.setItem("name", data.name);
            localStorage.setItem("photo", data.photo);
            state.name = data.name;
            state.photo = data.photo;
        }
    },
    actions: {
        login(context, data) {
            context.commit("denglu", data);
        },
        logout(context) {
            context.commit("logout");
        },
        update(context, data) {
            context.commit("update", data);
        }

    },
    module: {

    }
};
export default User;